import { defineStore } from 'pinia'

export const useAppStore = defineStore('app', {
  state: () => ({
    dark: false,
  }),
  persist: {
    key: 'admin_app'
  },
  actions: {
    toggleDark(to?: boolean) {
      this.dark = typeof to === 'boolean' ? to : !this.dark
      if (this.dark) document.documentElement.classList.add('dark')
      else document.documentElement.classList.remove('dark')
    },
  },
})

